﻿using CoachingOrganizer.Toolkit.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoachingOrganizer.Logic.Models.Tools.EmotionsPack
{
    public class EmotionTraceItemModel
    {
        private string _traceItemName;
        private byte[] _tracePicture;

        public string TraceItemName
        {
            get { return _traceItemName; }
            set { _traceItemName = value; }
        }

        public byte[] TracePicture
        {
            get { return _tracePicture; }
            set { _tracePicture = value; }
        }      
        
        internal Func<ActionResult> RemoveDelegate;

        internal Func<ActionResult> SaveDelegate;

        internal Func<string> GetEmotionNameDelegate;

        public EmotionTraceItemModel()
        {

        }

        public async Task<ActionResult> Remove()
        {
            Func<ActionResult> removeDelegate = RemoveDelegate;
            return removeDelegate == null ? ActionResult.GetErrorResult(new NotSupportedException()) : await Task.Run(() => removeDelegate());
        }

        public async Task<ActionResult> Save()
        {
            Func<ActionResult> saveDelegate = SaveDelegate;
            return saveDelegate == null ? ActionResult.GetErrorResult(new NotSupportedException()) : await Task.Run(() => saveDelegate());
        }

        public string GetEmotionName()
        {
            return GetEmotionNameDelegate();
        }
    }
}
